package com.example.freeengine.wallpaper.persistence.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.example.freeengine.wallpaper.persistence.entity.WallPaperCycleRefreshAlbum;
import com.google.common.util.concurrent.ListenableFuture;

import java.util.List;

/**
 * @author Terry Deng
 */
@Dao
public interface WallPaperCycleRefreshAlbumDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    ListenableFuture<Long> insert(WallPaperCycleRefreshAlbum wallPaperCycleRefreshAlbum);

    @Delete
    ListenableFuture<Integer> delete(WallPaperCycleRefreshAlbum wallPaperCycleRefreshAlbum);

    @Query("select * from wallpaper_cyclerefresh_album where id = :id")
    LiveData<WallPaperCycleRefreshAlbum> findById(Long id);

    @Query("select * from wallpaper_cyclerefresh_album order by id desc")
    LiveData<List<WallPaperCycleRefreshAlbum>> findAll();

    @Update
    ListenableFuture<Integer> update(WallPaperCycleRefreshAlbum wallPaperCycleRefreshAlbum);
}
